﻿using System.Windows.Media;

using Styx.Common;
using Styx.CommonBot;
using Styx.WoWInternals.WoWObjects;

namespace WuzzCollection.Helpers
{
    internal static class Spell
    {
        #region Spellcasting Methods
        public static bool CastBuff(string BuffName, WoWUnit Target = null)
        {
            if (SpellManager.CanCast(BuffName))
            {
                if (SpellManager.Cast(BuffName, Target))
                {
                    Logging.Write(Colors.LightBlue, "{0} - Buff: {1}", WuzzCollection.BotSettings.Name, BuffName);
                    return true;
                }
            }
            return false;
        }

        public static bool CastSpell(string SpellName, WoWUnit Target = null)
        {
            if (SpellManager.CanCast(SpellName))
            {
                if (SpellManager.Cast(SpellName, Target))
                {
                    Logging.Write(Colors.Red, "{0} - Attack: {1}", WuzzCollection.BotSettings.Name, SpellName);
                    return true;
                }
            }
            return false;
        }

        public static bool CastSpecial(string SpellName, WoWUnit Target = null)
        {
            if (SpellManager.CanCast(SpellName))
            {
                if (SpellManager.Cast(SpellName, Target))
                {
                    Logging.Write(Colors.DarkOrange, "{0} - Special: {1}", WuzzCollection.BotSettings.Name, SpellName);
                    return true;
                }
            }
            return false;
        }

        public static bool CastHeal(string SpellName, WoWUnit Target = null)
        {
            if (SpellManager.CanCast(SpellName))
            {
                if (SpellManager.Cast(SpellName, Target))
                {
                    Logging.Write(Colors.LightGreen, "{0} - Heal: {1}", WuzzCollection.BotSettings.Name, SpellName);
                    return true;
                }
            }
            return false;
        }
        #endregion

        // Check if spell is on cooldown
        public static bool Cooldown(string SpellName)
        {
            if (SpellManager.Spells.ContainsKey(SpellName) && SpellManager.Spells[SpellName].Cooldown) { return true; }
            return false;
        }

        // Check if we have learned a spell
        public static bool HasSpell(string SpellName)
        {
            if (SpellManager.Spells.ContainsKey(SpellName)) { return true; }
            return false;
        }
    }
}
